/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/03/15
* File: MeshLODLevel.cpp
* Blog: http://www.cnblogs.com/zengqh/
**/

#include "MeshLODLevel.h"

namespace HY
{
MeshLODLevel::MeshLODLevel(Mesh* mesh)
: mesh_(mesh)
, ib_(0)
{

}

MeshLODLevel::~MeshLODLevel()
{
	clearIndexBuffer();
	clearGeometries();
}

Mesh* MeshLODLevel::getMesh() const
{
	return mesh_;
}

void MeshLODLevel::setMesh(Mesh* mesh)
{
	mesh_ = mesh;
}

float MeshLODLevel::getLODDistance() const
{
	return distance_;
}

void MeshLODLevel::setLODDistance(float dis)
{
	distance_ = dis;
}

void MeshLODLevel::clearIndexBuffer()
{
	HY_SAFE_DELETE(ib_);
}

void MeshLODLevel::createIndexBuffer()
{
	clearIndexBuffer();
	ib_ = mesh_->getRenderSys()->createIndexBuffer();
}

IndexBuffer* MeshLODLevel::getIndexBuffer() const
{
	return ib_;
}	

void MeshLODLevel::clearGeometries()
{
	HY_SAFE_DELETE(geometry_list_);
}

void MeshLODLevel::createGeometries()
{
	geometry_list_ = new std::vector<Geometry>;
}

std::vector<Geometry>* MeshLODLevel::getGeometries() const
{
	return geometry_list_;
}

}